﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BCCommon;
using BCDto.Common.OA.WeeklyPuncheditsStatistics;
using BCService.CommonService.OA.WeeklyPunchEditsStatistics;
using BlackCoffeeRESTful.Configs;
using Microsoft.AspNetCore.Mvc;

namespace BlackCoffeeRESTful.Controllers.Management.OA
{
    /// <summary>
    /// 每周工时统计服务接口
    /// </summary>
    [ApiExplorerSettings(GroupName = "OAAdmin")]
    [Route("api/v1/sim/[controller]")]
    public class WeeklyPunchEditsStatisticsController : ManagementBaseController
    {
        private readonly IWeeklyPunchEditsStatisticsService weeklyPunchEditsStatisticsService;

        public WeeklyPunchEditsStatisticsController(IWeeklyPunchEditsStatisticsService weeklyPunchEditsStatisticsService)
        {
            this.weeklyPunchEditsStatisticsService = weeklyPunchEditsStatisticsService;
        }

        #region 创建一条每周工时统计信息
        /// <summary>
        /// 创建一条每周工时统计信息
        /// </summary>
        /// <param name="weeklyPunchEditsStatisticsRequestDto">每周工时统计创建请求模型</param>
        /// <response code="200">新创建的每周工时统计信息</response>
        /// <returns></returns>
        [HttpPost]
        [Log("创建一条每周工时统计信息")]
        [ProducesResponseType(typeof(WeeklyPunchEditsStatisticsDto), 200)]
        public IActionResult Post([FromBody] WeeklyPunchEditsStatisticsRequestDto weeklyPunchEditsStatisticsRequestDto)
        {
         
            return Ok(this.weeklyPunchEditsStatisticsService.Create(this.Admin, weeklyPunchEditsStatisticsRequestDto));
        }
        #endregion

        #region 修改一条每周工时统计信息

        /// <summary>
        /// 修改每周工时统计信息
        /// </summary>
        /// <param name="weeklyPunchEditsStatisticsNo">每周工时统计Id</param>
        /// <param name="weeklyPunchEditsStatisticsSimPutDto">每周工时统计修改请求模型</param>        
        /// <returns></returns>
        /// <response code="200">修改后的每周工时统计信息。</response>
        [HttpPut("{weekly_punch_edits_statistics_no}")]
        [Log("修改每周工时统计信息")]
        [ProducesResponseType(typeof(WeeklyPunchEditsStatisticsDto), 200)]
        public IActionResult Put([FromRoute(Name = "weekly_punch_edits_statistics_no")] string weeklyPunchEditsStatisticsNo, [FromBody]  WeeklyPunchEditsStatisticsSimPutDto weeklyPunchEditsStatisticsSimPutDto)
        {
           
            return this.Ok(this.weeklyPunchEditsStatisticsService.Update(weeklyPunchEditsStatisticsNo, weeklyPunchEditsStatisticsSimPutDto));
        }

        #endregion

        #region 删除一条每周工时统计信息
        /// <summary>
        /// 删除一条每周工时统计信息
        /// </summary>
        /// <param name="weeklyPunchEditsStatisticsNo">每周工时统计Id</param>
        /// <returns></returns>
        /// <response code="204">刪除一条每周工时统计信息成功。</response>
        [HttpDelete("{weekly_punch_edits_statistics_no}")]
        [Log("删除一条每周工时统计信息")]
        public IActionResult Delete([FromRoute(Name = "weekly_punch_edits_statistics_no")]string weeklyPunchEditsStatisticsNo)
        {
            this.weeklyPunchEditsStatisticsService.Delete(weeklyPunchEditsStatisticsNo);
            return NoContent();
        }
        #endregion

        #region 获取一条每周工时统计信息
        /// <summary>
        /// 获取一条每周工时统计信息
        /// </summary>
        /// <param name="weeklyPunchEditsStatisticsNo">每周工时统计ID</param>
        /// <returns></returns>
        [HttpGet("{weekly_punch_edits_statistics_no}")]
        [ProducesResponseType(typeof(WeeklyPunchEditsStatisticsDto), 200)]

        public IActionResult Get([FromRoute(Name = "weekly_punch_edits_statistics_no")] string weeklyPunchEditsStatisticsNo)
        {
            return Ok(this.weeklyPunchEditsStatisticsService.Get(weeklyPunchEditsStatisticsNo));
        }

        #endregion

        #region 获取每周工时统计信息接口（分页）
        /// <summary>
        /// 获取每周工时统计信息列表（分页）
        /// </summary>
        /// <param name="adminFullName">员工姓名</param>
        /// <param name="idCard">身份证</param>
        /// <param name="phone">手机号</param>
        /// <param name="adminId">员工ID</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>       
        /// <param name="ascending">排序</param>
        /// <param name="pageIndex">以 1 起始的页码 (默认 1)。</param>
        /// <param name="pageSize">每页要显示的行数 (默认 10)。</param>
        /// <response code="200">带有分页信息的每周工时统计信息列表。</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<WeeklyPunchEditsStatisticsDto>), 200)]
        public IActionResult List([FromQuery(Name = "user_name")]string adminFullName,
            [FromQuery(Name = "id_card")]string idCard,
            [FromQuery(Name = "phone")]string phone,
            [FromQuery(Name = "admin_id")] long? adminId,
            [FromQuery(Name = "start")]DateTime? start,
            [FromQuery(Name = "end")]DateTime? end,
            [FromQuery(Name = "ascending")]bool? ascending,
            int pageIndex = 1,
            int pageSize = 10)
        {
            var list = this.weeklyPunchEditsStatisticsService.List(adminFullName, idCard, phone, adminId, start, end, ascending, pageIndex, pageSize);
            return this.Ok(list);

        }
        #endregion
    }
}